<?php




class Display_record extends CI_Controller {

	public function __construct() {
		parent::__construct(); 
                // the tutorial shows this as 
                // parent::Controller();
                
                $this->load->helper(array('form','url'));
                $this->load->library('form_validation');
	}

	public function index() {
		$this->load->view('testing/placeholder_view');
                
                        $user_id = '1';
                
                        // get an object by ID
                        //$user = $this->doctrine->em->find('ORM\Testing\User', $user_id);
                        $user = $this->doctrine->em->find('ORM\Dynasties2\Users', $user_id);
                        echo $user->getfirst_Name().' '.$user->getlastname().' is a real chill guy.<br />';
                        

                        // get a related object
                        $article = $this->doctrine->em->find('ORM\Testing\Article', $user_id);
                        $user = $article->getUser();
                        echo $user->getFirstName().' '.$user->getLastName().' thinks CodeIgniter + Doctrine is real slick. <br />';

                        // what happens when we try to get an object that doesn't exist?
                        $article = $this->doctrine->em->find('ORM\Testing\Article', 9001);
                        if(is_null($article))
                        {
                            // the "find" call returns NULL!
                            echo 'Dude, that article number 9001 doesn\'t even exist yet.<br />';
                        }

                        // get an object by another field
                        
                        //$other_field = 'joel@joelverhagen.com';
                        $other_field = 'bobby@bobbybrown.com';
                        
                        $user = $this->doctrine->em->getRepository('ORM\Testing\User')->findOneBy(array('email' => $other_field));
                        echo $user->getFirstName().' '.$user->getLastName().' is glad he isn\'t dealing with Symfony.<br />';
                


        }
}

